<?php

/**
 * @author Martin Pernica
 * @copyright 2008
 */
 echo '<h2><a href="index.php?p=build">Zpět</a></h2><br />';
 
 if(!empty($_POST['type'])){
    if($_POST['type'] == 'module'){
        $module_path = './modules/'.$_POST['module'].'/'.$_POST['module'].'.php';
	}else{
        $module_path = '';
	}
    $query = $GLOBALS['db']->query("INSERT INTO ".$GLOBALS['db_prefix']."rightblock (type, text, module_path, weigh, active) VALUES('".$_POST['type']."', '".$_POST['text']."', '".$module_path."', '".$_POST['weigh']."', '".intval($_POST['active'])."')") or die($GLOBALS['db']->error);
	echo '<h2>Položka byla vložena !</h2>';
 }
 
echo '<form action="'. $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'] .'" method="POST">
<table>
<tr><td>Typ :</td><td><select name="type" size="1">
<option value="text">Text</option><option value="module" selected="selected">Modul</option></select>
</td></tr>
<tr><td>Text (nepovinné u typu modul):</td></tr>
<tr><td><textarea name="text" cols="40"  rows="5" class="wysiwyg" ></textarea></td></tr>
<tr><td>Modul (nepovinné u typu text):</td><td>
<select name="module" size="1">
<option value=" "> </option>
';
$modules = dirlist('../modules');
for($i = 0; !empty($modules[$i]); $i++){
	echo '<option value="'.$modules[$i].'">'.$modules[$i].'</option>';
}
echo '
</select>
</td></tr>
<tr><td>Váha :</td><td><input type="text" name="weigh" size="10" value="1" /></td></tr>
<tr><td>Aktivní :</td><td><input type="checkbox" name="active" value="1" checked="checked" /></td></tr>
<tr><td><input type="submit" value="Odeslat" /></td></tr>
</table>
</form>
';
?>